package de.stefanocke.roo.wicket.form.enumselect;

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.springframework.roo.classpath.itd.ItdTypeDetailsProvidingMetadataItem;

import de.stefanocke.roo.wicket.RooEnumSelect;
import de.stefanocke.roo.wicket.Stereotypes;
import de.stefanocke.roo.wicket.base.ModelClassAwareItdMetadataProviderBase;
import de.stefanocke.roo.wicket.base.ModelClassAwareMetadataCreationParams;
import de.stefanocke.roo.wicket.form.FormComponentMetadata;

@Component
@Service
public class EnumSelectMetadataProvider extends
		ModelClassAwareItdMetadataProviderBase<EnumSelectMetadata, EnumSelectAnnotationValues> {

	public EnumSelectMetadataProvider() {
		super(RooEnumSelect.class, EnumSelectMetadata.class, EnumSelectAnnotationValues.class, FormComponentMetadata.class);
	}

	@Override
	protected ItdTypeDetailsProvidingMetadataItem getMetadataInternal(
			ModelClassAwareMetadataCreationParams<EnumSelectAnnotationValues> cmcp) {
		if (!cmcp.getModelClassTypeDetails().isEnumType()) {
			return null;
		}
		return new EnumSelectMetadata(cmcp);
	}

	@Override
	protected String requiredStereotype() {
		return Stereotypes.ENUM_SELECT;
	}
}
